import graph.CorrelationGraphGenerator;

import java.util.List;

import preprocessor.AlertPreprocessor;

import correlation.CorrelationEngine;

import kb.KnowledgeBase;
import dom.Alert;

/**
 * @author Alex
 */
public class Main {

	public static void main(String[] args) {

		long start = now();
		System.out.println("Starting alert correlation");
		try{

			KnowledgeBase kb = KnowledgeBase.getInstance();
			
			AlertPreprocessor alertPreprocessor = new AlertPreprocessor();
			alertPreprocessor.initialize();
			
			CorrelationEngine ce = new CorrelationEngine();
			List<Alert> alerts = alertPreprocessor.getAlerts();
			ce.initialize(alerts);
			ce.run(ce.getHyperAlerts());
			
			CorrelationGraphGenerator cgg = new CorrelationGraphGenerator(ce.getHyperAlertCorrelationNodes());
			cgg.run();
		}
		catch(Exception e){
			e.printStackTrace();
			System.exit(1);
		}
		System.out.println("Ending alert correlation");
		System.out.println("alert Correlation took " + (now()-start) + " ms.");
		System.exit(0);
	}
	
	private static long now(){
		return System.currentTimeMillis();
	}

}
